package com.sun.alen.mapper;

import com.sun.alen.entity.Profession;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ProfessionMapper {
    @Select("select * from profession limit #{start},#{pageSize}")
    List<Profession> list(Integer start, Integer pageSize);

    @Select("select COUNT(*) from profession")
    Long count();

    @Insert("INSERT INTO profession( professionName,professionType) " +
            "VALUES( #{professionName}, #{professionType})")
    boolean add(Profession profession);

    @Update("update profession set professionName=#{professionName},professionType=#{professionType} " +
            "where professionId=#{professionId}")
    boolean update(Profession profession);

    @Delete("delete from profession where professionId=#{id}")
    boolean delete(String id);

    @Select("select * from profession where professionName like #{input} limit #{start},#{pageSize}")
    List<Profession> searchByName(String input, Integer start, Integer pageSize);

    @Select("select count(*) from profession where professionName like #{input} ")
    long countByName(String input);

    @Select("select * from profession where professionType like #{input} limit #{start},#{pageSize}")
    List<Profession> searchByType(String input, Integer start, Integer pageSize);

    @Select("select count(*) from profession where professionType like #{input} ")
    long countByType(String input);

    @Select("select * from profession")
    List<Profession> all();

    @Select("select * from profession where professionName like #{input}")
    List<Profession> searchIdByName(String input);
}
